Creating custom property types
Properties are containers for different types of values with a common interface. This interface enables you to use properties in several places, such as scene graph and materials. For example, Kanzi provides all material values, including shader uniforms, as properties.In Kanzi properties are formed using two structures: property and property type. Property type defines what the property is like, including name, data type, and default value, while property defines a value. Each property is linked to a corresponding property type. Most of the property implementations are containers for basic primitives or structures, such as Booleans, floats, colors, and vectors, but can include other information too.
Note that animations can only animate floating point numbers. So, to animate properties that have more than one value (for example, color and transformation), you can split the property data into a set of floating point property data attributes (for example, the RGBA channels in a color property type).
Creating a custom property
To create a custom property:
- In the Library right-click Property Types and select Create Property Type.
Property Type Editor opens.
- In the Property Type Editor set:
- In the Naming section set the Name and Display Name for your property.
- In the Type section define the type of your property which determines what kind of data it can hold. You can use one of these data types:
- Boolean stores values True or False and has no type-specific properties.
- Color stores color information for red, green, blue, and alpha channels (RGBA).
Note that even though in Kanzi Studio you can set color values for hue, saturation, light, and alpha channels (HSLA), Kanzi stores them in RGBA. This means you can animate only RGBA values. - Enumeration stores a set of key value pairs, so that each unique key resolves to a unique integer.
- Float stores single precision floating point values.
- Integer stores 32-bit signed integer values.
- Light stores sets of properties to define custom light types. The properties are available in the light objects that use them, and in the material types that use these light property types.
- Matrix 3x3 stores 3x3 matrices of floating point numbers, which you can use to store transformations for 2D objects.
- Matrix 4x4 stores 4x4 matrices of floating point numbers, which you can use to store transformations for 3D objects.
- Message represents messages, which you can use to add message triggers for application event messages.
- Project item stores references to objects and does not have type-specific properties. You can use Project item data type only in application code, for which Kanzi converted the property into the path of the target in a string format.
- Property type stores references to other property types. You can use Property type data types only in application code, for which Kanzi converts the property into the name of the target in a string format.
- Text stores plain text and does not have type-specific properties.
- Texture stores references to textures and does not have type-specific properties.
- Vector 2D stores vectors of two floating point numbers.
- Vector 3D stores vectors of three floating point numbers.
- Vector 4D stores vectors of four floating point numbers.
- In the Type Specific section you can set the lower and upper value limits for your property, and, if you are using a slider editor for the property, you can set the value for the slider step.
- In the Value section you can set the default value and sorting index for your property.
- Click Save.
You can now use the property you created just like any other property in Kanzi.
See also
Property types
Open topic with navigation